import React from 'react'

class BaseInfoApp extends React.Component {

    componentDidMount() {
        console.log('BaseInfoApp#componentDidMount/' + JSON.stringify(this.props.user));
        if (!this.props.user.nickName)
            this.props.getUserInfo();
    }

    render() {
        return <div>{this.props.user ? (this.props.user.nickName + "") : "UnKnown"}</div>
    }
}

// -----------------------************************-----------------------

import {connect} from 'react-redux';
import {getUserInfo} from "./../../redux/action";
import Api from "./../../Api"

const mapStateToProps = (state, ownProps) => ({
    user: state.user
});

const mapDispatchToProps = (dispatch, ownProps) => ({
    getUserInfo: ()=> {
        dispatch(Api.getUserInfo(getUserInfo));
    }
});

const BaseInfo = connect(
    mapStateToProps,
    mapDispatchToProps
)(BaseInfoApp);

console.log('BaseInfo#Loaded');

export default BaseInfo;


